package com.visionork.android.twe.parser;

import java.net.URL;
import java.util.ArrayList;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import com.visionork.android.twe.activity.Show;

public class VarietyShowAdapterImpl implements ShowAdapter {
	
	private static final String SHOW_URL = "http://sugoideas.com/variety-shows/";

	@Override
	public ArrayList<Show> get_show_list() throws Throwable {
		ArrayList<Show> show_list = new ArrayList<Show>();
		URL url = new URL(SHOW_URL);
		Document doc = Jsoup.parse(url, 5000);
		Elements elms = doc.getElementsByTag("a");
		for (Element elm : elms) {
			Elements imgElms = elm.getElementsByTag("img");
			if (imgElms != null && imgElms.size() == 1) {
				show_list.add(new Show(imgElms.get(0).attr("title"), elm
						.attr("href")));
			}

		}
		return show_list;
	}
	
}
